package com.pureut.system.controller;

import java.util.Arrays;
import java.util.List;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.system.domain.DocumentManagement;
import com.pureut.system.domain.vo.DocumentManagementVo;
import com.pureut.system.domain.vo.SupplierPerformanceVo;
import com.pureut.system.service.IDocumentManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



/**
 * @Author: pureut
 * @Date: 2024-12-06 13:51:19
 * @Desc: 文档管理Controller
 */
@RestController
@RequestMapping("/documentManagement")
public class DocumentManagementController extends BaseController {

    /**
     * 文档管理Service
     */
    @Autowired
    private IDocumentManagementService documentManagementService;

    /**
     * 查询文档管理列表
     * @param: params 参数列表
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("documentManagement-list")
    @GetMapping("/list")
    public TableDataInfo list( DocumentManagementVo documentManagementVo) {
        startPage();
        return getDataTable(documentManagementService.queryPage(documentManagementVo));
    }



    /**
     * 获取文档管理详细信息
     * @param: id 文档管理主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("documentManagement-query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(documentManagementService.getById(id));
    }

    /**
     * 新增文档管理
     * @param: documentManagement 文档管理对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("documentManagement-add")
    @PostMapping
    public AjaxResult add(@RequestBody DocumentManagementVo documentManagementVo) {
        return toAjax(documentManagementService.save(documentManagementVo));
    }

    /**
     * 修改文档管理
     * @param: documentManagement 文档管理对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("documentManagement-edit")
    @PutMapping
    public AjaxResult edit( @RequestBody DocumentManagementVo documentManagementVo) {
        return toAjax(documentManagementService.updateById(documentManagementVo));
    }

    /**
     * 删除文档管理
     * @param: id 文档管理主键
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("documentManagement-remove")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(documentManagementService.removeByIds(Arrays.asList(ids)));
    }

    /**
     * 审核
     * @param: supplierAccess 供应商准入对象
     * @return: Json工具类对象
     */
    //    @SaCheckPermission("supplierAccess-edit")
    @PutMapping("/examine")
    public AjaxResult examine(@RequestBody DocumentManagementVo documentManagementVo) {
        return toAjax(documentManagementService.examine(documentManagementVo));
    }
}
